package com.itheima.controller;

import com.itheima.pojo.Person;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/***
 * 描述
 * @author ljh
 * @packagename com.itheima.controller
 * @version 1.0
 * @date 2020/1/5
 */
@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/index")
    public String showIndex(Model model){
        model.addAttribute("message","hello world");
        //显示集合数据
        List<Person> personList = new ArrayList<Person>();
        personList.add(new Person(1001L,"特冷普"));
        personList.add(new Person(1002L,"obama"));
        personList.add(new Person(1003L,"三胖"));
        model.addAttribute("list",personList);

        model.addAttribute("myparam","12345");

        //循环遍历map
        Map<String,Object> maps = new HashMap<String, Object>();
        maps.put("no",12345);
        maps.put("address","深圳宝安");
        model.addAttribute("mymap",maps);

        //日期的输出
        model.addAttribute("date",new Date());
        model.addAttribute("age",18);
        return "index";
    }
}
